<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/06/10
// +----------------------------------------------------------------------

namespace app\erp\validate;

use think\Validate;

/**
 * 公共类 验证器 调拨管理
 * @package app\admin\validate
 * @author dou<51779987@qq.com>
 */
class Allocation extends Validate
{

    protected $rule = [
        // 'user_id'	            =>  'require|number',
        'id'		        =>  'require|number|gt:0',
        'from_warehouse_id'	=>  'require|number|gt:0',
		'to_warehouse_id'	=>  'require|number|gt:0',
        //'remarks'	        =>  'require',
        'handled_by'	    =>  'require',
        'code'		        =>  'require|unique:erp_goods_allocation,code^id',
        // 'sku'	            =>  'require|array'
    ];

    protected $message  =   [
        'user_id' 		            => 'user_id格式错误',
        'id' 			            => 'id格式错误',
        'from_warehouse_id.require' => '调出仓不能为空',
        'from_warehouse_id.number' 	=> '调出仓格式错误',
        'to_warehouse_id.require' 	=> '调入仓不能为空',
        'to_warehouse_id.number' 	=> '调入仓格式错误',
        //'remarks.numbe' 	        => '备注不能为空',
        'handled_by.require' 	    => '经办人不能为空',
        'code.require'		        => '调拨单号不能为空',
        'code.unique'		        => '调拨单号已存在',
        'sku' 	                    => '货物信息不能为空',
    ];

    //验证场景
    protected $scene = [
        'allocation_list'=>  [//列表
            'user_id',
        ],
        'allocation_add'=>  [//添加
            'user_id',
            'from_warehouse_id',
            'to_warehouse_id',
            //'remarks',
            'handled_by',
            'code',
            'sku'
        ],
        'allocation_outgoing'=>  [//出库审核id
            'user_id',
            'id',
        ],
    ];
}
